// async load files from same domain
var load = function(url, callBack, strict, posts, asynchronous, slot){
	// asynchronous or not
	if(typeof(asynchronous) == "undefined") asynchronous = true;
	if(asynchronous != true) asynchronous = false;
	// cache slot
	if(slot == true) url += ((url.indexOf("?")>-1)?"&slot=":"?slot=") + new Date().getTime().toString().substr(6);
	// http object
	var httpReq = getHTTPObject();
	if(asynchronous){
		httpReq.onreadystatechange = function(){
			if(httpReq.readyState == 4){
				// FF or IE
				if(httpReq.responseXML == null || httpReq.responseXML.firstChild == null){
					if(strict == "strictXml"){
						rec = false;
						if(browser.isIE){
							// for loading local files with IE
							rec = new ActiveXObject("Microsoft.XMLDOM");
							rec.loadXML(httpReq.responseText);
						}
					} else var rec = httpReq.responseText;
				} else var rec = httpReq.responseXML;
				(typeof(callBack) == "string") ? eval(callBack)(rec) : callBack(rec);
			}
		};
	}
	// get or post
	if(isArray(posts)){
		var postData = "";
		for(var i in posts) postData += encodeURIComponent(i) + "=" + encodeURIComponent(posts[i]) + "&";
		if(postData.lengh > 0) postData = postData.slice(0, postData.length - 1);
		httpReq.open("POST", url, asynchronous);
		httpReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		httpReq.setRequestHeader("Content-length", postData.length);
		httpReq.setRequestHeader("Connection", "close");
		httpReq.send(postData);
	} else{
		httpReq.open("GET", url, asynchronous);
		httpReq.send(null);
	}
	// response for synchronious calls
	if(!asynchronous){
		if(strict == "strictXml") rec = httpReq.responseXML;
		else rec = httpReq.responseText;
		if(typeof(callBack) == "string") eval(callBack)(rec);
		else if(typeof(callBack) == "function") callBack(rec);
		else return rec;
	}
};

//Browser-neutral XMLHttpRequest object
var getHTTPObject = function(){
	var xmlhttp;
	if(browser.isWin && browser.isIE){
		try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e){
		try{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }catch(E){ xmlhttp = false; }
	}
	} else if(!xmlhttp && typeof XMLHttpRequest != 'undefined'){
		try{ xmlhttp = new XMLHttpRequest(); }catch(e){ xmlhttp = false; }
	}
	return xmlhttp;
};

// injection of child objects from xml documents with equal namespaces into xhtml document.
var adoptChilds = function(contentTg, childs, replace){
	if(browser.isIE){
		if(replace) contentTg.innerHTML = "";
		for(var t=0; t<childs.length; t++){
			contentTg.innerHTML += childs[t].xml;
		}
	} else{
		// remove all content elements
		if(replace) while(contentTg.childNodes.length > 0){ contentTg.removeChild(contentTg.firstChild ); }
		// inject new content elements
		for(var t=0; t<childs.length; t++){
			contentTg.appendChild(childs[t]);
		}
	}
};

//alternate XMLSerializer
if(!window.XMLSerializer){
	XMLSerializer = function(){}; XMLSerializer.prototype.serializeToString = function(oNode){ return oNode.xml; };
};

//xml to string translator using XMLSerializer
var serializeXml2str = function(src){
	if(src.nodeType >= 2 && src.nodeType <= 4) return src.nodeValue;
	else return new XMLSerializer().serializeToString(src);
};
